/* Note: 	firm_reg_data_final produces summary stat table
			
*  Input: 	firm_reg_final.dta
			
*  Tables:  Table 4 
			
*/

clear all

grstyle set plain, horizontal grid
grstyle set color Set1


********************************************************************************
*	Firm-level Summary Stats (Table 4)
********************************************************************************
use "./Data/firm_reg_final.dta", clear


local firm_control Assets_USDm_PRE TotalNotionalNetA_PRE Sales_USDm_PRE TotalNotionalNetS_PRE ///
				   TotalNumCpty_PRE  Leverage_PRE GrossProfMargin_PRE ///
				   FCARatio_PRE FCLRatio_PRE ExpShare_PRE Export_hedge_PRE FCL_hedge_PRE ///
				   Cash_bal_A_ts_PRE Borr_A_ts_PRE   ///
				   IntExp_A_ts_PRE 
				  
local var="Exposed"

keep if Year==2009 //otherwise you get dupes
eststo full: quietly estpost summarize `firm_control' if `var'==0 | `var'==1
eststo exposed: quietly estpost summarize `firm_control' if  `var'==1			   
eststo nonexposed: quietly estpost summarize `firm_control' if  `var'==0	
eststo diff: quietly estpost ttest `firm_control', by(`var') unequal

esttab exposed nonexposed diff, mtitles("Exposed" "Non-Exposed" "Diff") ///
cells("mean(pattern(1 1 0) fmt(2)) b(star pattern(0 0 1) fmt(2)) t(pattern(0 0 1) par fmt(2))") label

esttab full exposed nonexposed, mtitles("FullSample" "Exposed" "Non-Exposed") cells("mean(pattern(1 1) fmt(%12.3fc)) sd(pattern(1 1) fmt(3))") label nonumber replace

esttab full exposed nonexposed diff, mtitles("Full Sample" "Exposed" "Non-Exposed" "Difference") cells("mean(pattern(1 1 1 0) fmt(%12.3fc)) sd(pattern(1 1 1 0) fmt(2)) b(star pattern(0 0 0 1) fmt(2)) t(pattern(0 0 0 1) par fmt(2))") label nonumber replace


///// EXPORT: TABLE 4. Firm Summary Stat ///////////////////////////////////////
local fn="./Output/Table_4_firm_summary_stat_v10_R2.tex"

esttab full exposed nonexposed diff using `fn', mtitles("Full Sample" "Exposed" "Non-Exposed" "Difference") cells("mean(pattern(1 1 1 0) fmt(%12.3fc)) sd(pattern(1 1 1 0) fmt(2)) b(star pattern(0 0 0 1) fmt(2)) t(pattern(0 0 0 1) par fmt(2))") label nonumber replace



